#include <stdio.h>
#include "bufferQue.h"


int tesBufferQue(){
    int i, j;
    int success = 1;
    
    bufferQue BQ;
   
    bMakeEmpty(&BQ);
    if (!bIsEmpty(BQ)) {success = 0;}
    
    for (i = 0 ; i < 128; ++i){
        bEnque(&BQ, i);
    }
    if (bLen(BQ) != 128) {success = 0;}
    
    for (i = 0 ; i < 64; ++i){
        bDeque(&BQ);
    }    
    if (bLen(BQ) != 64) {success = 0;}
    
    for (i = 0 ; i < 32; ++i){
        bEnque(&BQ, i);
    }
    
    if (bLen(BQ) != 96) {success = 0;}
    
    
    for (i = 0 ; i < 96; ++i){
        bDeque(&BQ);
    }
    if (!bIsEmpty(BQ)) {success = 0;}
    
    for (i = 0 ; i < 96; ++i){
        bEnque(&BQ, i);    
        if (bDeque(&BQ) != i) {success = 0;}
    }
    
    for (i = 0 ; i < 256; ++i){
        bEnque(&BQ, i);
    }
    if (bLen(BQ) != 128) {success = 0;}
    if (bIsEmpty(BQ)) {success = 0;}
    bMakeEmpty(&BQ);
    if (!bIsEmpty(BQ)) {success = 0;}
    
    return success;
}

int main()
{   
    printf("BufferQueTest\n");
	
    printf("tesBufferQue: %s\n",(tesBufferQue())?"OK":"FAIL");
    return 0;
    
}

